﻿using Cart.DAL;
using Cart.model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cart.Bll
{
    public class UserBll
    {
        UserDAl da = new UserDAl();
        public List<Users> getuser(string name, string pwd)
        {
            var ob = da.user().Where(a => a.loginName == name && a.loginPwd == pwd).ToList();

            return ob;
        }
        public List<Users> pagelist(int page, int limit, string name, out int count)
        {
            var us = da.user();
            if (!string.IsNullOrWhiteSpace(name))
            {
                us = us.Where(a => a.userName.Contains(name));
            }
            count = us.Count();

            var ob = us.OrderBy(a => a.userID).Skip((page - 1) * limit).Take(limit).ToList();
            return ob;
        }
   //删除操作
        public int det(int uid) 
        {
            da.det(uid);
            return da.save();

        }

        //批量删除操作
        public int detall(int[] ids)
        {
            da.detall(ids);
            return da.save();
        }
          //添加操作  
        public int AddUser(Users us)
        {
            da.AddUser(us);
            return da.save();
        }
    }
}
